﻿using HR60_PanelSoft.Model;
using HR60_PanelSoft.Model.BaseModel;
using HR60_PanelSoft.NetWork.Base;
using HR60_PanelSoft.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HR60_PanelSoft.NetWork.Sender
{
    class Sender_0108:BaseSender
    {
        public Sender_0108(byte panelNo, Panel panel)
        {
            bool isChangjing = false;

            bool isDeng = true;

            bool isBeiJing = false;

            bool isAir = false;

            bool isHeat = false;

            bool isWind = false;

            bool isMianBanPeiZhi = true;

            List<LoadPin> loadPins = panel.loadPins;
         
            List<Scene> scenes = Proj.currentProj.scenes;

            if (!CollectionUtils.isBlank(scenes))
                isChangjing = true;


            if (panel.bgmPage!=null &&(!CollectionUtils.isBlank(panel.bgmPage.buttons)))
            {
                    isBeiJing = true;
            }
            if (panel.airconPage != null && (!CollectionUtils.isBlank(panel.airconPage.buttons)))
            {
                    isAir = true;
            }
            if (panel.heatingPage != null && (!CollectionUtils.isBlank(panel.heatingPage.buttons)))
            {
                    isHeat = true;
             }
             if (panel.newWindPage != null && (!CollectionUtils.isBlank(panel.newWindPage.buttons)))
             {
                    isWind = true;
             }
               
         

            byte[] data = new byte[28];
            int cur = 0;

            {
                data[cur++] = 1;
                data[cur++] = (byte)(isChangjing ? 0x01 : 0x00);
            }

            {
                data[cur++] = 2;
                data[cur++] = (byte)(isDeng ? 0x01 : 0x00);
            }

            {
                data[cur++] = 3;
                data[cur++] = (byte)(isBeiJing ? 0x01 : 0x00);
            }

            {
                data[cur++] = 4;
                data[cur++] = (byte)(isAir ? 0x01 : 0x00);
            }

            {
                data[cur++] = 5;
                data[cur++] = (byte)(isHeat ? 0x01 : 0x00);
            }

            {
                data[cur++] = 6;
                data[cur++] = (byte)(isWind ? 0x01 : 0x00);
            }

            {
                data[cur++] = 7;
                data[cur++] = (byte)(isMianBanPeiZhi ? 0x01 : 0x00);
            }

            this.package = Package.getPackage(0x01, 0x08, panelNo,0x01, data);

        }

    }
}
